package org.ossean.gather.targetDao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface PointerDao {

//	// 读取表中最小id值
//	@Select("select min(id) from ${table}")
//	public int getMinId(@Param("table") String table);
//
//	// 读取表中最大id值
//	@Select("select max(id) from ${table}")
//	public int getMaxId(@Param("table") String table);

	@Select("select Pointer from ${table} where SourceTableName=#{SourceTableName} and TargetTableName=#{TargetTableName}")
	public int getPointer(@Param("table") String table,
			@Param("SourceTableName") String SourceTableName,
			@Param("TargetTableName") String TargetTableName);

	@Update("update ${table} set Pointer=#{Pointer} where SourceTableName=#{SourceTableName} and TargetTableName=#{TargetTableName}")
	public void updatePointer(@Param("table") String table,
			@Param("SourceTableName") String SourceTableName,
			@Param("TargetTableName") String TargetTableName,
			@Param("Pointer") int Pointer);

	@Insert("insert into ${table} (`SourceTableName`,`TargetTableName`,`Pointer`) values (#{SourceTableName},#{TargetTableName},#{Pointer})")
	public void insertPointer(@Param("table") String table,
			@Param("SourceTableName") String SourceTableName,
			@Param("TargetTableName") String TargetTableName,
			@Param("Pointer") int Pointer);

}
